package com.ophiux.micro.core.domain;

public class DomainResult<T> {

	/***静态集合***/
	public static boolean RESULT_SUCCESS = true;
	public static boolean RESULT_FAIL = false;
	
	private boolean isSuccess;
	private String msg;
	private String errorCode;	//错误码
	private T RESPONSE;
	
	public DomainResult(boolean isSuccess, String errorCode , String msg) {
		this.isSuccess = isSuccess;
		this.msg = msg;
		this.errorCode = errorCode;
	}
	
	public DomainResult(boolean isSuccess, String msg, String errorCode, T rESPONSE) {
		super();
		this.isSuccess = isSuccess;
		this.msg = msg;
		this.errorCode = errorCode;
		RESPONSE = rESPONSE;
	}



	public boolean isSuccess() {
		return isSuccess;
	}
	public void setSuccess(boolean isSuccess) {
		this.isSuccess = isSuccess;
	}
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}
	public String getErrorCode() {
		return errorCode;
	}
	public void setErrorCode(String errorCode) {
		this.errorCode = errorCode;
	}
	public T getRESPONSE() {
		return RESPONSE;
	}
	public void setRESPONSE(T rESPONSE) {
		RESPONSE = rESPONSE;
	}
	
	
	public static <T> DomainResult<T> success() {
		return new DomainResult<T>(RESULT_SUCCESS , "100", "");
	}
	
	public static <T> DomainResult<T> success(String msg) {
		return new DomainResult<T>(RESULT_SUCCESS , "100" , msg);
	}
	
	public static <T> DomainResult<T> success(T reponse) {
		return new DomainResult<T>(RESULT_SUCCESS, "", "100", reponse);
	}
	
	public static <T> DomainResult<T> fail(String errorCode , String msg) {
		return new DomainResult<T>(RESULT_FAIL , errorCode , msg);
	}
	
	public static <T> DomainResult<T> success(String msg , T reponse) {
		return new DomainResult<T>(RESULT_SUCCESS , "100" , msg , reponse);
	}
	
}
